﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Quick.Common.Plugin;

namespace Quick.PluginFramework
{
    public class ExtensionMessage : IExtensionMessage
    {
        private static readonly List<Extension> _extensionList = new List<Extension>();

        public event EventHandler<ExtensionEventArgs> ExtensionChanged;

        public List<Extension> ExtensionList
        {
            get { return _extensionList; }
        }

        public void AddExtensions(List<Extension> extensions)
        {
            foreach (var extension in extensions)
            {
                AddExtension(extension);
            }
        }

        public void AddExtension(Extension extensions)
        {
            ExtensionList.Add(extensions);
            OnExtensionChanged(new ExtensionEventArgs() {Extension = extensions});
        }

        private void OnExtensionChanged(ExtensionEventArgs args)
        {
            if (this.ExtensionChanged != null) 
                this.ExtensionChanged.Invoke(this, args);
        }
    }
}